


//侧边栏布局
const sider =  (function (title,width,height,groups){
    return {
        title: title,
        search(cell, keyword) {
            return cell.shape.indexOf(keyword) !== -1
        },
        placeholder: '请输入字符',
        notFoundText: '未找到',
        stencilGraphWidth: width,
        stencilGraphHeight: height,
        groups: groups
    }
})('查询',220,180,[
    {name: 'dataSource', title: '数据源', collapsable: false},
    {name: 'compute', title: '算子', collapsable: false},
    {name: 'result', title: '结果', collapsable: false},
    ]
);



//数据源
const data = function (width,height,innerText,compareField,compareType,compareVal){
    return {
        width: width,
        height: height,
        attrs: {
            circle: { fill: '#FE854F', strokeWidth: 3, stroke: '#4B4A67' },
            text: { text: innerText, fill: '#fff',textWrap: {width: width, height: height, ellipsis: true} },
            field: { compareField: compareField,compareType: compareType,compareVal:compareVal } //自定义字段对象
        },
        ports: {
            groups: {
                out: {
                    position: 'bottom',
                    attrs: {
                        circle: {
                            r: 4,
                            magnet: true,
                            stroke: '#FE854F',
                            strokeWidth: 2,
                            fill: '#fff',
                        },
                    },
                },
            },
            items: [
                {
                    id: 'dataFrom',
                    group: 'out',
                },
            ],
        },
    }
}


//算子
const compute = function (width,height,innerText,compute,weightX,weightY){
    return {
        width: width,
        height: height,
        attrs: {
            rect: { fill: '#31D0C6', stroke: '#4B4A67', strokeWidth: 3 },
            text: { text: innerText, fill: '#fff',textWrap: {width: width, height: height, ellipsis: true} },
            compute: compute
        },
        ports: {
            groups: {
                in: {
                    position: 'top',
                    attrs: {
                        circle: {
                            r: 4,
                            magnet: true,
                            stroke: '#31d0c6',
                            strokeWidth: 2,
                            fill: '#fff',
                        },
                    },
                },
                out: {
                    position: 'bottom',
                    attrs: {
                        circle: {
                            r: 4,
                            magnet: true,
                            stroke: '#31d0c6',
                            strokeWidth: 2,
                            fill: '#fff',
                        },
                    },
                },
            },
            items: [
                {
                    id: 'parameter1',
                    group: 'in',
                    weight: weightX, //参数权重
                },
                {
                    id: 'parameter2',
                    group: 'in',
                    weight: weightY, //参数权重
                },
                {
                    id: 'result',
                    group: 'out',
                },
            ],
        }
    }
}

//结果
const result = function (width,height,innerText){
    return {
        width: width,
        height: height,
        attrs: {
            rect: { fill: '#feb663', strokeWidth: 3, stroke: '#4B4A67' },
            text: { text: innerText, fill: '#fff',textWrap: {width: width, height: height, ellipsis: true} },
            result: 'result'
        },
        ports: {
            groups: {
                in: {
                    position: 'top',
                    attrs: {
                        circle: {
                            r: 4,
                            magnet: true,
                            stroke: '#31d0c6',
                            strokeWidth: 2,
                            fill: '#fff',
                        },
                    },
                },
            },
            items: [
                {
                    id: 'dataResult',
                    group: 'in',
                },
            ],
        },
    }
}




export {
    data,
    compute,
    result,
    sider
}
